import { Tag } from 'ant-design-vue';
import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.UserListPageResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumnItem[] = [
  {
    title: '用户ID',
    align: 'center',
    dataIndex: 'userId',
    hideInTable: true,
    hideInSearch: true,
  },
  {
    title: '用户姓名',
    dataIndex: 'name',
    hideInSearch: false,
    align: 'center',
  },
  {
    title: '工号/编号',
    align: 'center',
    hideInSearch: true,
    dataIndex: 'userNo',
  },
  {
    title: '部门/主单位',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
    dataIndex: 'orgId',
  },

  {
    title: '所在部门',
    dataIndex: 'deptName',
    hideInSearch: true,
    align: 'center',
  },
  {
    title: '人员类别',
    align: 'center',
    dataIndex: 'orgType',
    hideInSearch: true,
    hideInTable: true,
  },
  {
    title: '性别',
    dataIndex: 'userSex',
    align: 'center',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: [
          {
            label: '男',
            value: 1,
          },
          {
            label: '女',
            value: 0,
          },
        ],
      },
    },
    customRender: ({ record }) => {
      const isEnable = record.userSex === 1;
      return <Tag color={isEnable ? 'success' : 'success'}>{isEnable ? '男' : '女'}</Tag>;
    },
  },
  {
    title: '登录名',
    align: 'center',
    dataIndex: 'userAccount',
  },
  {
    title: '部门/主岗位',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
    dataIndex: 'mainPost',
  },

  {
    title: '直属领导',
    dataIndex: 'directLeader',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '直属领导',
    dataIndex: 'leaderName',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '人员图片',
    align: 'center',
    hideInSearch: true,
    hideInTable: true,
    dataIndex: 'picture',
  },
  {
    title: '职级',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
    dataIndex: 'userStaff',
  },
  {
    title: '职务',
    dataIndex: 'staffLevel',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '联系电话',
    dataIndex: 'phoneNumber',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '邮寄地址',
    dataIndex: 'postAddress',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '双因子验证',
    dataIndex: 'doubleValidation',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '关联帐号',
    dataIndex: 'relatedAccount',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '是否启用',
    dataIndex: 'IS_ENABLED',
    align: 'center',
    hideInSearch: true,
    formItemProps: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: '是',
              value: 1,
            },
            {
              label: '否',
              value: 0,
            },
          ],
        },
      },
      customRender: ({ record }) => {
        const isEnable = record.IS_ENABLED === 1;
        return <Tag color={isEnable ? 'success' : 'red'}>{isEnable ? '是' : '否'}</Tag>;
      },
  },
  {
    title: '是否业务相关',
    dataIndex: 'IS_BUSINESS',
    align: 'center',
    hideInSearch: true,
    hideInTable: true,
    formItemProps: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: '是',
              value: 1,
            },
            {
              label: '否',
              value: 0,
            },
          ],
        },
      },
      customRender: ({ record }) => {
        const isEnable = record.IS_ENABLED === 0;
        return <Tag color={isEnable ? 'success' : 'red'}>{isEnable ? '是' : '否'}</Tag>;
      },
  },
  {
    title: '关键字',
    dataIndex: 'keyWords',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '排序号',
    dataIndex: 'personSort',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
  {
    title: '备注',
    dataIndex: 'remark',
    hideInSearch: true,
    hideInTable: true,
    align: 'center',
  },
];
